#include<stdio.h>
#include<ctype.h>

//int main()
//{ 
//	char s[] = "-12345";
//	int ret = atoi(s);
//	printf("%d", ret);
//	return 0;
//}
int my_atoi(const char* s)
{
	while (isspace(*s))
	{
		s++;
	}
	int flag = 1;
	if (*s == '+')
	{
		flag = 1;
	}
	else if (*s == '-')
	{
		flag = -1;
	}
	s++;
	int ret = 0;
	while (*s != '\0')
	{
		if (isdigit(*s))
		{
			ret = ret * 10 + *s - '0';
		}
		else
			return ret*flag;
		s++;
	}
	return ret*flag;
}
int main()
{
	char s[] = "-42we1";
	int ret = my_atoi(s);
	printf("%d ", ret);
	return 0;
}
